package org.joverseer.tools.combatCalc;

import org.joverseer.domain.ClimateEnum;
import org.joverseer.domain.NationRelationsEnum;
import org.joverseer.metadata.domain.HexTerrainEnum;

/**
 * Holds various lookup info with combat modifiers.
 * 
 * TODO: Move this information to a file.
 * 
 * @author Marios Skounakis
 *
 */
public class CombatModifiers {
    static int terr_clim_mod[][] = new int[][] {
            /*           NONE */
            {100, 100, 100, 100, 100, 100, 100,
            100, 100, 100, 100, 100, 100, 100,
            100, 100, 100, 100, 100, 100, 100,
            100, 100, 100, 100, 100, 100, 100,
            100, 100, 100, 100, 100, 100, 100,
            100, 100, 100, 100, 100, 100, 100,
            100, 100, 100, 100, 100, 100, 100},
            /*           WOODMEN */
            {90, 90, 90, 95, 87, 85, 85, 
            92, 92, 92, 97, 90, 87, 87, 
            95, 95, 95, 100, 92, 90, 90, 
            97, 97, 97, 102, 95, 92, 92, 
            100, 100, 100, 105, 97, 95, 95, 
            97, 97, 97, 102, 95, 92, 92, 
            95, 95, 95, 100, 92, 90, 90},
            /*           NORTHMEN */
            {87, 87, 82, 80, 77, 77, 80, 
            90, 90, 85, 82, 80, 80, 82, 
            92, 92, 87, 85, 82, 82, 85,
            95, 95, 90, 87, 85, 85, 87, 
            100, 100, 95, 92, 90, 90, 92, 
            97, 97, 92, 90, 87, 87, 90, 
            95, 95, 90, 87, 85, 85, 87}, 
            /*           EOTHRAIM */
            {87, 97, 87, 77, 82, 77, 77, 
            90, 100, 90, 80, 85, 80, 80, 
            92, 102, 92, 82, 87, 82, 82, 
            95, 105, 95, 85, 90, 85, 85, 
            100, 110, 100, 90, 95, 90, 90, 
            100, 110, 100, 90, 95, 90, 90, 
            95, 105, 95, 85, 90, 85, 85}, 
            /*           ARTHEDAIN */
            {90, 92, 90, 85, 85, 82, 85, 
            92, 95, 92, 87, 87, 85, 87, 
            95, 97, 95, 90, 90, 87, 90, 
            97, 100, 97, 92, 92, 90, 92, 
            100, 102, 100, 95, 95, 92, 95, 
            100, 102, 100, 95, 95, 92, 95, 
            95, 97, 95, 90, 90, 87, 90}, 
            /*           CARDOLAN */
            {92, 90, 90, 85, 85, 82, 85, 
            95, 92, 92, 87, 87, 85, 87, 
            97, 95, 95, 90, 90, 87, 90, 
            100, 97, 97, 92, 92, 90, 92, 
            102, 100, 100, 95, 95, 92, 95, 
            102, 100, 100, 95, 95, 92, 95, 
            97, 95, 95, 90, 90, 87, 90}, 
            /*           NORTHERN GONDOR */
            {92, 92, 87, 85, 85, 82, 85, 
            95, 95, 90, 87, 87, 85, 87, 
            97, 97, 92, 90, 90, 87, 90, 
            100, 100, 95, 92, 92, 90, 92, 
            102, 102, 97, 95, 95, 92, 95, 
            102, 102, 97, 95, 95, 92, 95, 
            97, 97, 92, 90, 90, 87, 90}, 
            /*           SOUTHERN GONDOR */
            {90, 90, 90, 85, 85, 82, 85, 
            92, 92, 92, 87, 87, 85, 87, 
            95, 95, 95, 90, 90, 87, 90, 
            97, 97, 97, 92, 92, 90, 92, 
            100, 100, 100, 95, 95, 92, 95, 
            100, 100, 100, 95, 95, 92, 95, 
            95, 95, 95, 90, 90, 87, 90}, 
            /*           DWARVES */
            {92, 95, 100, 85, 92, 92, 105, 
            95, 97, 102, 87, 95, 95, 107, 
            97, 100, 105, 90, 97, 97, 110, 
            97, 100, 105, 92, 97, 97, 110, 
            97, 100, 105, 95, 97, 97, 110, 
            97, 100, 105, 95, 97, 97, 110, 
            95, 97, 102, 90, 95, 95, 107}, 
            /*           SINDA ELVES */
            {92, 90, 87, 100, 87, 85, 85, 
            95, 92, 90, 102, 90, 87, 87, 
            97, 95, 92, 105, 92, 90, 90, 
            100, 97, 95, 107, 95, 92, 92, 
            102, 100, 97, 110, 97, 95, 95, 
            102, 100, 97, 110, 97, 95, 95, 
            97, 95, 92, 105, 92, 90, 90}, 
            /*           NOLDO ELVES */
            {95, 92, 90, 97, 90, 87, 87, 
            97, 95, 92, 100, 92, 90, 90, 
            100, 97, 95, 102, 95, 92, 92, 
            102, 100, 97, 105, 97, 95, 95, 
            102, 100, 97, 105, 97, 95, 95, 
            102, 100, 97, 105, 97, 95, 95, 
            97, 95, 92, 100, 92, 90, 90}, 
            /*           WITCH KING */
            {90, 90, 90, 85, 82, 82, 87, 
            92, 92, 92, 87, 85, 85, 90, 
            95, 95, 95, 90, 87, 87, 92, 
            97, 97, 97, 92, 90, 90, 95, 
            100, 100, 100, 95, 92, 92, 97, 
            97, 97, 97, 92, 90, 90, 95, 
            95, 95, 95, 90, 87, 87, 90}, 
            /*           DRAGON LORD */
            {82, 87, 85, 85, 80, 80, 82, 
            85, 90, 87, 87, 82, 82, 85, 
            87, 92, 90, 90, 85, 85, 87, 
            90, 95, 92, 92, 87, 87, 90, 
            95, 100, 97, 97, 92, 92, 95, 
            95, 100, 97, 97, 92, 92, 95, 
            95, 100, 97, 97, 92, 92, 95}, 
            /*           DOG LORD */
            {90, 92, 87, 80, 85, 82, 85, 
            92, 95, 90, 82, 87, 85, 87, 
            95, 97, 92, 85, 90, 87, 90, 
            97, 100, 95, 87, 92, 90, 92, 
            102, 105, 100, 92, 97, 95, 97, 
            102, 105, 100, 92, 97, 95, 97, 
            102, 105, 100, 92, 97, 95, 97}, 
            /*           CLOUD LORD */
            {87, 87, 85, 82, 85, 82, 85, 
            90, 90, 87, 85, 87, 85, 87, 
            92, 92, 90, 87, 90, 87, 90, 
            95, 95, 92, 90, 92, 90, 92, 
            100, 100, 97, 95, 97, 95, 97, 
            100, 100, 97, 95, 97, 95, 97, 
            100, 100, 97, 95, 97, 95, 97}, 
            /*           BLIND SORCERER */
            {90, 87, 85, 80, 85, 80, 85, 
            92, 90, 87, 82, 87, 82, 87, 
            95, 92, 90, 85, 90, 85, 90, 
            97, 95, 92, 87, 92, 87, 92, 
            102, 100, 97, 92, 97, 92, 97, 
            102, 100, 97, 92, 97, 92, 97, 
            102, 100, 97, 92, 97, 92, 97}, 
            /*           ICE KING */
            {92, 92, 90, 90, 85, 85, 90, 
            95, 95, 92, 92, 87, 87, 92, 
            97, 97, 95, 95, 90, 90, 95, 
            97, 97, 95, 95, 90, 90, 95, 
            100, 100, 97, 97, 92, 92, 97, 
            100, 100, 97, 97, 92, 92, 97, 
            97, 97, 95, 95, 90, 90, 95}, 
            /*           QUIET AVENGER */
            {90, 87, 90, 82, 87, 77, 80, 
            92, 90, 92, 85, 90, 80, 82, 
            95, 92, 95, 87, 92, 82, 85, 
            97, 95, 97, 90, 95, 85, 87, 
            102, 100, 102, 95, 100, 90, 92, 
            105, 102, 105, 97, 102, 92, 95, 
            102, 100, 102, 95, 100, 90, 92}, 
            /*           FIRE KING */
            {87, 87, 87, 82, 87, 80, 85, 
            90, 90, 90, 85, 90, 82, 87, 
            92, 92, 92, 87, 92, 85, 90, 
            95, 95, 95, 90, 95, 87, 92, 
            100, 100, 100, 95, 100, 92, 97, 
            100, 100, 100, 95, 100, 92, 97, 
            100, 100, 100, 95, 100, 92, 97}, 
            /*           LONG RIDER */
            {87, 92, 87, 77, 85, 80, 85, 
            90, 95, 90, 80, 87, 82, 87, 
            92, 97, 92, 82, 90, 85, 90, 
            95, 100, 95, 85, 92, 87, 92, 
            100, 105, 100, 90, 97, 92, 97, 
            97, 102, 97, 87, 95, 90, 95, 
            97, 102, 97, 87, 95, 90, 95}, 
            /*           DARK LIEUTENANTS */
            {87, 87, 85, 82, 85, 82, 85, 
            90, 90, 87, 85, 87, 85, 87, 
            92, 92, 90, 87, 90, 87, 90, 
            95, 95, 92, 90, 92, 90, 92, 
            100, 100, 97, 95, 97, 95, 97, 
            100, 100, 97, 95, 97, 95, 97, 
            100, 100, 97, 95, 97, 95, 97}, 
            /*           CORSAIRS */
            {90, 87, 85, 82, 85, 80, 77, 
            92, 90, 87, 85, 87, 82, 80, 
            95, 92, 90, 87, 90, 85, 82, 
            97, 95, 92, 90, 92, 87, 85, 
            102, 100, 97, 95, 97, 92, 90, 
            102, 100, 97, 95, 97, 92, 90, 
            100, 97, 95, 92, 95, 90, 87}, 
            /*           HARADWAITH */
            {90, 87, 90, 80, 87, 77, 80, 
            92, 90, 92, 82, 90, 80, 82, 
            97, 95, 97, 87, 95, 85, 87, 
            100, 97, 100, 90, 97, 87, 90, 
            102, 100, 102, 92, 100, 90, 92, 
            105, 102, 105, 95, 102, 92, 95, 
            102, 100, 102, 92, 100, 90, 92}, 
            /*           DUNLENDINGS */
            {87, 87, 92, 85, 85, 85, 92, 
            90, 90, 95, 87, 87, 87, 95, 
            92, 92, 97, 90, 90, 90, 97, 
            95, 95, 100, 92, 92, 92, 100, 
            100, 100, 105, 97, 97, 97, 105, 
            97, 97, 102, 95, 95, 95, 102, 
            95, 95, 100, 92, 92, 92, 100}, 
            /*           RHUDAUR */
            {90, 90, 92, 92, 85, 82, 85, 
            92, 92, 95, 95, 87, 85, 87, 
            95, 95, 97, 97, 90, 87, 90, 
            97, 97, 100, 100, 92, 90, 92, 
            100, 100, 102, 102, 95, 92, 95, 
            100, 100, 102, 102, 95, 92, 95, 
            95, 95, 97, 97, 90, 87, 90}, 
            /*           EASTERLINGS */
            {87, 92, 85, 80, 85, 77, 77, 
            90, 95, 87, 82, 87, 80, 80, 
            92, 97, 90, 85, 90, 82, 82, 
            95, 100, 92, 87, 92, 85, 85, 
            100, 105, 97, 92, 97, 90, 90, 
            97, 102, 95, 90, 95, 87, 87, 
            97, 102, 95, 90, 95, 87, 87}};
    
    public static int getModifierFor(int nationNo, HexTerrainEnum terrain, ClimateEnum climate) {
        int ci = 0;
        if (climate == ClimateEnum.Polar) {
            ci = 0;
        } else if (climate == ClimateEnum.Severe) {
            ci = 1;
        } else if (climate == ClimateEnum.Cold) {
            ci = 2;
        } else if (climate == ClimateEnum.Cool) {
            ci = 3;
        } else if (climate == ClimateEnum.Mild) {
            ci = 4;
        } else if (climate == ClimateEnum.Warm) {
            ci = 5;
        } else if (climate == ClimateEnum.Hot) {
            ci = 6;
        }  
        int ti = 0;
        if (terrain == HexTerrainEnum.shore) {
            ti = 0;
        } else if (terrain == HexTerrainEnum.plains) {
            ti = 1;
        } else if (terrain == HexTerrainEnum.hillsNrough) {
            ti = 2;
        } else if (terrain == HexTerrainEnum.forest) {
            ti = 3;
        } else if (terrain == HexTerrainEnum.desert) {
            ti = 4;
        } else if (terrain == HexTerrainEnum.swamp) {
            ti = 5;
        } else if (terrain == HexTerrainEnum.mountains) {
            ti = 6;
        } 
        int j = ci * 7 + ti;
        return terr_clim_mod[nationNo][j];
    }
    
    public static int getRelationModifier(NationRelationsEnum relations) {
        if (relations == NationRelationsEnum.Hated) {
            return 125;
        } else if (relations == NationRelationsEnum.Disliked) {
            return 110;
        } else if (relations == NationRelationsEnum.Neutral) {
            return 100;
        } else if (relations == NationRelationsEnum.Tolerated) {
            return 90;
        } else if (relations == NationRelationsEnum.Friendly) {
            return 75;
        } 
        return 100;
    }
}
